/*
 * File:    ClientContextFactory.java
 * Created: 06-May-2007
 * Version: $Id$
 * 
 * COPYRIGHT (C) 2007, Bitgate Software, LLC.  All Rights Reserved.
 *
 * software@bitgatesoftware.com
 */

package com.bitgate.util.service.client;

import java.util.concurrent.atomic.AtomicLong;

import com.bitgate.util.socket.ClientChannel;

/**
 * This class is used to create new <code>ClientContext</code> objects used within the <code>Service</code>
 * class.  It contains an auto-incrementing counter to help control the automatically assigned client ID
 * when the class is requested from the factory.
 * 
 * @author kenji
 * @version $Id$
 */
public class ClientContextFactory
{
	private static final AtomicLong clientId = new AtomicLong();
		
	/**
	 * Creates a new instance of a <code>ClientContext</code> with an automatically assigned client ID.
	 * 
	 * @param cChannel The <code>ClientChannel</code> to apply.
	 * @return <code>ClientContext</code> object.
	 */
	public static ClientContext getContext(ClientChannel cChannel)
	{
		return new ClientContext(clientId.incrementAndGet(), cChannel);
	}
}